<?php
/*
	[UCenter Home] (C) 2007-2008 Comsenz Inc.
	$Id: admincp_spam.php 10621 2008-12-11 02:24:51Z liguode $
*/
if(!defined('IN_UCHOME') || (!defined('IN_ADMINCP') && $_SCONFIG['yoho_version'])) {
	exit('Access Denied');
}

//权限
if(!checkperm('manageconfig') && $_SCONFIG['yoho_version']) {
	cpmessage('no_authority_management_operation');
}


if( submitcheck('yohosubmit') || !$_SCONFIG['yoho_version']) {
	
	$_POST['config']['yoho_version'] = YOHO_VER;
	$_SCONFIG['yoho_version'] = YOHO_VER;

	if(empty($_POST['config']['yoho_indexFlashAlbum']))  $_POST['config']['yoho_indexFlashAlbum'] = 0;
	
	//首页幻灯片

	$setarr = array(
		'blocksql' => 'SELECT * FROM `uchome_pic` AS `pic` WHERE `pic`.`albumid` in ('.$_POST['config']['yoho_indexFlashAlbum'].') ORDER BY `pic`.`dateline` ASC',
		'htmlcode' => '<!--{loop $_SBLOCK[yoho_flashPIC] $value}--><a href="#"><img src="'.$_SC['attachurl'].'$value[filepath]" /></a><!--{/loop}-->'
	);
	if(!$_POST['config']['yoho_indexFlashAlbum']) {
		$setarr['htmlcode'] = '<a href="network.php"><img src="js/image/01.jpg" alt="" /></a>'
								. '<a href="#"><img src="js/image/02.jpg" alt="" /></a>'
								. '<a href="#"><img src="js/image/03.jpg" alt="" /></a>'
								. '<a href="#"><img src="js/image/04.jpg" alt="" /></a>';	
		$setarr['blocksql']	= '';
	}
	add_block('yoho_flashPIC',$setarr);
	
//	//居民秀
//	$setarr = array(
//		'blocksql' => "SELECT * FROM `".tname('space')."` AS `space` LEFT JOIN `".tname('spacefield')."` AS `spacefield` on `space`.`uid`=`spacefield`.`uid` WHERE `space`.`viewnum`>'0' AND `space`.`viewnum`<'52' AND `space`.`avatar`='1' ORDER BY `space`.`lastlogin` DESC, `space`.`updatetime` DESC, `space`.`credit` DESC",
//		'htmlcode' => '<ul>
//						<!--{loop $_SBLOCK[yoho_UserShow] $value}-->
//						<li>
//						<a href="'.getsiteurl().'space.php?uid=$value[uid]" title="$value[username]" target="_blank"><!--{avatar($value[uid],small)}--></a></li>
//						<!--{/loop}-->
//						</ul>'
//	);
//	add_block('yoho_UserShow',$setarr);
	
		//去除空的
		$datas = array();
		foreach ($_POST['data']['question'] as $key => $value) {
			$value = trim($value);
			$a_value = trim($_POST['data']['answer'][$key]);
			if($value && $a_value) {
				$datas['question'][] = $value;
				$datas['answer'][] = $a_value;
			}
		}
		if(empty($datas['question']) && $_POST['config']['questionmode']) {
			$_POST['config']['questionmode'] = 0;
		}
		data_set('yoho', $datas);

	//保存设置
	$setarr = array();
	foreach ($_POST['config'] as $var => $value) {
		$value = trim($value);
		$setarr[] = "('$var', '$value')";
	}
	if($setarr) {
		$_SGLOBAL['db']->query("REPLACE INTO ".tname('config')." (var, datavalue) VALUES ".implode(',', $setarr));
	}

	//更新缓存
	include_once(S_ROOT.'./source/function_cache.php');
	config_cache();
	
	if(defined('IN_ADMINCP')) cpmessage('do_success', 'admincp.php?ac=yoho');
}

$configs = array();
$query = $_SGLOBAL['db']->query("SELECT * FROM ".tname('config'));
while ($value = $_SGLOBAL['db']->fetch_array($query)) {
	$configs[$value['var']] = shtmlspecialchars($value['datavalue']);
}

$datas = data_get('yoho');
if($datas) $datas = unserialize($datas);
$onlineip = getonlineip();


?>